TRiggers Trouble

Hi Everybody,
I'm in trouble with the triggers:
I would like to create a trigger which when someone open a module update the some attribute.

Where I have to write the code? In which folder?

How the triggers work?
mikimichele82 - Wed Jul 22 05:02:01 EDT 2009

Re: TRiggers Trouble
mwilliamson - Wed Jul 22 12:00:57 EDT 2009

Hi,

I have found triggers quite tricky but recently had to do something very similar to your problem. The trigger code is embedded within the module by executing it within the target module. The trigger statement references a separate dxl file which contains the code to update the required attribute.

Trigger t = trigger("edited",module->"<Module>"->attribute->"<Attribute_name>",pre,modify,1,"#include <Path to dxl file>")

Trigger t = current
if ( !null t )
{
Object o = object(t)
if ( !null o )
{
bool amended = true
o."<attribute_name>" = <value>
}
}
Hope this helps

Mark

Re: TRiggers Trouble
mikimichele82 - Wed Jul 22 12:13:27 EDT 2009

mwilliamson - Wed Jul 22 12:00:57 EDT 2009
Hi,

I have found triggers quite tricky but recently had to do something very similar to your problem. The trigger code is embedded within the module by executing it within the target module. The trigger statement references a separate dxl file which contains the code to update the required attribute.

Trigger t = trigger("edited",module->"<Module>"->attribute->"<Attribute_name>",pre,modify,1,"#include <Path to dxl file>")

Trigger t = current
if ( !null t )
{
Object o = object(t)
if ( !null o )
{
bool amended = true
o."<attribute_name>" = <value>
}
}
Hope this helps

Mark

ok, Thank you very much for your answer.

I thought smth like this, but my trouble is: where I've to put, to save the following code:

Trigger t = trigger("edited",module->"<Module>"->attribute->"<Attribute_name>",pre,modify,1,"#include <Path to dxl file>")

when I have the module opened, what are the steps to integrate the comand in the module?

I guess that my question is clear!

Thank in advance

Michele

Re: TRiggers Trouble
vimo - Wed Jul 22 13:28:03 EDT 2009

mikimichele82 - Wed Jul 22 12:13:27 EDT 2009
ok, Thank you very much for your answer.

I thought smth like this, but my trouble is: where I've to put, to save the following code:

Trigger t = trigger("edited",module->"<Module>"->attribute->"<Attribute_name>",pre,modify,1,"#include <Path to dxl file>")

when I have the module opened, what are the steps to integrate the comand in the module?

I guess that my question is clear!

Thank in advance

Michele

Persistent Triggers are stored inside item they refer to: in Module if it is related to Module or Attribute.
So once you have executed suggested lines when save the module the trigger is permanently installed.

Quitely read DXL manual and have some tests.

Re: TRiggers Trouble
llandale - Wed Jul 22 14:08:39 EDT 2009

Look for 'Trigger' posts I've made to get a good idea of solid deploy/remove trigger commands. Perhaps search for 'Louie'.

The '#include' statement is discouraged since it requires everybody who might use that module to have access to the specified server path. That may work for closes DOORS systems but isn't realistic for more open ones. Instead, the deploy code could issue a 'readFile' command using the #include, then deploy in full that code. If you modify the code you must re-deploy the trigger, but the deployed code contains no #include statement making it universally available.

The code should check if the module has been open Edit.

If this code was to work on many modules you could change it to a project trigger, in which case the code would check the module name (or the existence of the attribute) to see if it really wants to update the attribute.

  • Louie